from loguru import logger

def main():
    # test_logger_level()
    test_logger_output()

def test_logger_level():
    logger.trace("This is a trace message!")
    logger.info("This is a info message!")
    logger.debug("This is a debug message!")
    logger.success("This is a success message!")
    logger.critical("This is a critical message!")
    logger.warning("This is a warning message!")
    logger.error("This is a error message!")

def test_logger_output():
    # 将DEBUG级别以上的日志格式化输出到file.log文件中
    logger.add("file.log", format="{time:YYYY-MM-DD HH:mm:ss} | {level} | {message}", level="DEBUG")
    test_logger_level()

if __name__ == '__main__':
    main()